<%@ page pageEncoding="UTF-8"%>
<%@ page contentType="text/html; charset=UTF-8"%>
<%@taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/fmt" prefix="fmt"%>
<% response.setHeader("Pragma","No-cache"); response.setHeader("Cache-Control","no-cache"); response.setDateHeader("Expires", 0);%>
<html lang="en">

<head>
	<meta charset="UTF-8">
	<title>修改密码</title>
	<link href="${pageContext.request.contextPath}/views/js/ligerUI/skins/Aqua/css/ligerui-all.css" rel="stylesheet" type="text/css" />
	<link href="${pageContext.request.contextPath}/views/js/ligerUI/skins/ligerui-icons.css" rel="stylesheet" type="text/css" />
	<script type="text/javascript" src="${pageContext.request.contextPath}/views/js/libs/jquery-1.6.min.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/views/js/libs/jquery.form.js"></script>
	<script type="text/javascript" src="${pageContext.request.contextPath}/views/js/md5.js"></script>
	<script src="${pageContext.request.contextPath}/views/js/ligerUI/js/core/base.js" type="text/javascript"></script>
	<script src="${pageContext.request.contextPath}/views/js/ligerUI/js/plugins/ligerDialog.js" type="text/javascript"></script>
	<style type="text/css">
		.fl{
			float: left;
		}
		.file p{
			font-size: 12px;
			line-height: 30px;
			color: #666;
			margin-bottom: 10px;
		}
		.file div{
			height: 20px;
		}
		.file input {
			margin-left: 20px;
			font-size: 12px;
			color: #666;
		}
		.file input[type=file] {
			background: #f0f0f0;
		}
		#ifopen{
			margin-top: 18px;
			margin-top: 13px \0;
			*margin-top: 13px;
		}
		.file .label_check{
			height: 50px;
			line-height: 50px;
		}
		.file div label{
			margin-left: 6px;
			color: #666;
			font-size: 12px;
		}
		.file .upload_btn {
			width: 230px;
			height: 30px;
			line-height: 30px;
			background: #346bd0;
			color: #fff;
			outline: none;
			border: none;
		}
	</style>
</head>

<body>
	<form id="resetpwd" action="${pageContext.request.contextPath }/user/resetpwd" method="post" method="post">
		<input type="hidden" name="id" value="${id }"/>
		<input type="hidden" name="pwd" id="pwd" />
		<table align="center" class="file" width="280">
			<tr>
				<td>
					用户名称：
				</td>
				<td>
					<input readonly="readonly" value="${name}"/>
				</td>
			</tr>
			<tr>
				<td>
					新密码：
				</td>
				<td>
					<input type="password" id="newpwd"/>		
				</td>
			</tr>
			<tr>
				<td>
					确认密码：
				</td>
				<td>
					<input type="password" id="confpwd"/>		
				</td>
			</tr>
			<tr>
				<td colspan="2">
					<input class="upload_btn" type="button" value="修改" onclick="resetpwd();" />
				</td>
			</tr>
		</table>
	</form>
</body>
<script type="text/javascript">
	function resetpwd(){
		var newpwd = $.trim($('#newpwd').val());
		var confpwd = $.trim($('#confpwd').val());
		if( newpwd != confpwd ){
			alert("两次输入密码不一致!");
			return false;
		}
		if(newpwd.length<6){
			alert("密码不能低于6位!");
			return false;
		}
		//newpwd = md5(newpwd);
		$('#pwd').val(newpwd);
		//ajax提交表单
		var option = {
			//url:"",//如果不定义url，就是用使用要提交的表单的action，如果定义了url那么就把表单中的action覆盖了
			//type:"post",//如果要提交的表单中已经提供了请求方法那就不要在这里定义了
			dataType:"json",
			async:false,
			success:function(res){
				if(res.code == 0){
					parent.$.ligerDialog.close();
					parent.operationTips('修改成功！');
				}else{
					operationTips('修改失败！');
				}
			},
			error:function(){
				operationTips('系统繁忙，请稍后重试！');
			}
					
		}
		$("#resetpwd").ajaxSubmit(option);
		
	}

	//操作提示
	function operationTips(content){
		$.ligerDialog.alert(content);
	}
</script>

</html>